package com.cykj.page05.util;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Properties;
import java.util.Set;

/**
 * @BelongsProject: HandTomcat
 * @BelongsPackage: com.cykj.page03.util
 * @Author: 阿隆
 * @CreateTime: 2025-10-29 20:24
 * @Description: 读取servlet配置文件
 * @Version: 1.0
 */
public class ServletUtils {

    private static HashMap<String, String> hashMap = new HashMap<>();

    static {
        try {
            Properties prop = new Properties();
            prop.load(new FileInputStream("config/servlet.properties"));

            //获取prperties这个配置文件所有的key
            Set<Object> keys = prop.keySet();

            //遍历set
            Iterator<Object> it = keys.iterator();

            while (it.hasNext()) {
                String key = (String) it.next();
                String value = prop.getProperty(key);

                hashMap.put(key, value);

            }


        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }


    /**
    * @Description: 根据请求模块获取类名
    * @Param: [key]
    * @return: java.lang.String
    */
    public static String getServletNameToKey(String key) {
        return hashMap.get(key);
    }


}